package cn.wolfcode.crm.config;

import cn.wolfcode.crm.web.interceptor.LoginInterceptor;
import cn.wolfcode.crm.web.interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *
 */
@Configuration //交给spring 代理的类
public class MVCJavaConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private PermissionInterceptor permissionInterceptor;
    //注册登录拦截器
    public void  addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(loginInterceptor)//传入拦截器对象
        .addPathPatterns("/**")    //拦截的规则
        .excludePathPatterns("/loginUser.do","/login.html","/css/**","/js/**");
        //排除掉这些不拦截


        //注册权限拦截器
        registry.addInterceptor(permissionInterceptor)//传入拦截器对象
                .addPathPatterns("/**")    //拦截的规则
                .excludePathPatterns("/loginUser.do","/login.html","/css/**","/js/**");
        //排除掉这些不拦截

    }


}

